package jjn.kamacoder.case42;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023-09-28 16:49
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            String[] commands = s.split(" ");
            String path = commands[1];
            String result = handlePath(path);
            System.out.println(result);
        }
    }
    
    static String handlePath(String path) {
        String[] parts = path.split("/");
        Deque<String> deque = new ArrayDeque<>();
        for (String part : parts) {
            if (part.isEmpty()) {
                continue;
            }
            if ("..".equals(part)) {
                deque.pollLast();
                continue;
            }
            if (".".equals(part)) {
                continue;
            }
            deque.offer(part);
        }
        return String.join("/", deque);
    }
}
